package com.example.demo07cache.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisMonitor;

public class MyJedisMonitor {

    public static void main(String[] args) throws Exception {
        MonitorTask monitorTask = new MonitorTask("192.168.43.76", 6379);
        new Thread(monitorTask).start();
    }
}

class MonitorTask implements Runnable {

    private String host;
    private int port;

    public MonitorTask(String host, int port) {
        this.host = host;
        this.port = port;
    }

    @Override
    public void run() {
        Jedis jedis = new Jedis(this.host, this.port);
        jedis.monitor(new JedisMonitor() {
            @Override
            public void onCommand(String command) {
                System.out.println(command);
            }
        });
    }
}
